package com.woniuxy.service.impl;

import com.netflix.hystrix.contrib.javanica.annotation.HystrixCollapser;
import com.netflix.hystrix.contrib.javanica.annotation.HystrixCommand;
import com.netflix.hystrix.contrib.javanica.annotation.HystrixProperty;
import com.woniuxy.api.RemoteProductServer;
import com.woniuxy.entity.Product;
import com.woniuxy.entity.utils.ResponseEntity;
import com.woniuxy.service.PriceService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.HashMap;
import java.util.Map;
import java.util.Random;

/**
 * @Author: 马宇航
 * @Description: TODO
 * @DateTime: 22/10/11/0011 17:08
 * @Component: 成都蜗牛学苑
 **/
@Service
public class PriceServiceImpl implements PriceService {
    @Autowired
    RemoteProductServer remoteProductServer;
    @Override
    public ResponseEntity searchPrice(Double floorPrice, Double ceilingPrice) {
//        Random random = new Random();
//        int i = random.nextInt(3-1+1) + 1;
//        if (i != 3){
//            try {
//                Thread.sleep(2000);
//            } catch (InterruptedException e) {
//                e.printStackTrace();
//            }
//        }
        //map的形式传参
        Product product = new Product();
        product.setPid(1);
        product.setName("Java从入门到精通");
        product.setPrice(70D);
        return remoteProductServer.searchPrice(product);
    }
}
